home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
stats
/
fdplot92.exe
/
T3.BAS
< prev
next >
Wrap
BASIC Source File
|
1992-08-15
|
6KB
|
179 lines
2000 REM Define graph position/orientation
2005 IF NF$="Y" THEN PRINT:INPUT" X min, X max for functions ";TMIN,TMAX
2050 PRINT" Rectangular or sqare plot (R/S)? _";
2051 GOSUB 8000
2060 IF A$<>"R" AND A$<>"S" THEN 2051 ELSE PRINT A$
2070 IF A$="S" THEN XLN%=YLN%*(1+INT(200/SZY%))
2090 PRINT:PRINT" SCALES: Regular, Grid or None? (R/G/N) _";
2091 GOSUB 8000
2095 IF A$<>"R" AND A$<>"G" AND A$<>"N" THEN 2091 ELSE PRINT A$
2100 SC$=A$
2105 IF SC$="N" THEN GOTO 2117
2110 PRINT:INPUT" Enter X-title (max 20 characters) or ─┘ ",XTITLE$
2115 INPUT" Enter Y-title (max 20 characters) or ─┘ ",YTITLE$
2117 IF NF$="Y" THEN INPUT " Function detail? (-1 to +1, or ─┘) ";DTL
2120 CLS
2125 REM PLOT X TITLE
2130 IF LEN(XTITLE$)=0 THEN 2150
2142 LOCATE (25+YADD%),40
2145 PRINT XTITLE$;
2150 REM END XTITLE
2155 REM PLOT Y TITLE
2160 IF LEN(YTITLE$)=0 THEN 2185
2175 LOCATE 1,2
2180 PRINT YTITLE$;
2185 REM END YTITLE
2190 RETURN
3000 REM Functions/data-sets retrieval, plot axes and scales
3050 REM Retreive data sets
3055 IF ND$="N" THEN 3115
3065 FM$="PLOTD"
3070 OPEN "I",#1,FM$
3075 INPUT #1,DTSN
3085 FOR J=1 TO DTSN
3090 INPUT #1,DATX(J),DATY(J)
3095 NEXT J
3100 INPUT #1,CORL$
3105 CLOSE #1
3115 REM FIND DATA SET MAX/MIN
3120 IF ND$="N" THEN 3180
3125 TEMP=DATX(1):TEMP2=DATY(1)
3130 XMIN=TEMP:XMAX=TEMP
3135 YMIN=TEMP2:YMAX=TEMP2
3145 FOR J=1 TO DTSN
3150 IF DATX(J)<XMIN THEN XMIN=DATX(J)
3155 IF DATX(J)>XMAX THEN XMAX=DATX(J)
3160 IF DATY(J)<YMIN THEN YMIN=DATY(J)
3165 IF DATY(J)>YMAX THEN YMAX=DATY(J)
3170 NEXT J
3180 REM END DATA MAX/MIN
3185 REM FIND FUNCTIONS MAX/MIN
3190 IF NF$="N" THEN 3265
3200 IF ABS(DTL) > .88 THEN DTL=SGN(DTL)*.88
3203 DTL=SGN(DTL)*SQR(ABS(DTL))
3205 TINC=(TMAX-TMIN)/50/(1.1+DTL)*(1.1-DTL) 'Try 50 divisions for functions
3210 T=TMIN:X=T:GOSUB 1100
3215 IF ND$="N" THEN YMIN=Y:YMAX=Y:XMIN=X:XMAX=X
3220 FOR T=TMIN TO TMAX STEP TINC
3225 X=T
3235 GOSUB 1100
3240 IF Y<YMIN THEN YMIN=Y
3245 IF Y>YMAX THEN YMAX=Y
3250 IF X<XMIN THEN XMIN=X
3255 IF X>XMAX THEN XMAX=X
3260 NEXT T
3265 REM END FUNCT TEST
3270 REM DRAW SCALES AND AXES
3280 REM SELECT Y SCALES
3285 A=LOG(YMAX-YMIN)*.434294:IF A<0 THEN A1=A+ABS(INT(A)) ELSE A1=A-INT(A)
3290 A2=10^(A-A1):YF=A2 '
3295 A3=INT(YMIN/A2) '
3300 A4=A3*A2 '
3305 SY=INT(YMAX/A2+.95)-A3 '
3310 NTC%=.007*SZY%
3315 IF SY<5 THEN RN=.5 ELSE RN=1 '
3317 IF SY=1 THEN RN=.2
3320 IF SC$="N" THEN 3400
3325 FOR RI=0 TO SY STEP RN
3330 REM PRINT SCALE #'S
3335 XPP=-.041*SZX%:YPP=RI*YLN%/SY-NTC% '
3340 GOSUB 6000
3350 YTITLE$=STR$(A3+RI)
3355 PRINT YTITLE$
3360 REM
3365 MOVE$="B"
3370 IF SC$="R" THEN XPP=NTC%*4 ELSE XPP=XLN%
3372 YPP=YPP+NTC%:GOSUB 5010
3375 XPP=0:GOSUB 5010
3380 IF RI=SY THEN 3390
3385 YPP=(RI+RN)*YLN%/SY:GOSUB 5010
3390 NEXT RI
3400 REM SELECT X SCALES
3405 B=LOG(XMAX-XMIN)*.434294:IF B<0 THEN B1=B+ABS(INT(B)) ELSE B1=B-INT(B)
3410 B2=10^(B-B1):XF=B2
3415 B3=INT(XMIN/B2)
3420 B4=B3*B2
3425 SX=INT(XMAX/B2+.95)-B3
3430 IF SX<5 THEN RN=.5 ELSE RN=1
3433 IF SX=1 THEN RN=.2
3435 TEMPX=XLN%/SX/XF:TEMPY=YLN%/SY/YF
3440 IF SC$="N" THEN 3515
3445 FOR RI=0 TO SX STEP RN
3450 REM
3455 YPP=-5*NTC%:XPP=RI*XLN%/SX-2*NTC%
3460 GOSUB 6000
3465 XTITLE$=STR$(B3+RI)
3466 IF (B3+RI>=0) THEN XTITLE$=MID$(STR$(B3+RI),2)
3470 PRINT XTITLE$;
3475 REM
3472 MOVE$="B"
3480 IF SC$="R" THEN YPP=4*NTC% ELSE YPP=YLN%
3485 XPP=XPP+2*NTC%:GOSUB 5010
3490 YPP=0:GOSUB 5010 ' write notch
3495 IF RI=SX THEN 3510
3500 XPP=(RI+RN)*XLN%/SX:GOSUB 5010
3510 NEXT RI
3515 REM
3520 REM
3525 IF SC$="N" THEN RETURN
3530 XTITLE$="(Scale: X/"+MID$(STR$(XF),2)+", Y/"+MID$(STR$(YF),2)+")"
3535 LOCATE (25+YADD%),5
3540 PRINT XTITLE$;
3545 RETURN
4000 IF NF$="N" THEN 4110
4005 REM
4010 STP=.02*SZX%/(1.1+DTL)*(1.1-DTL)
4015 T=TMIN:GOSUB 1100
4020 GOSUB 5040
4025 X1=X%:Y1=Y%:TINCTMP=TINC
4028 T=TMIN+TINC:GOSUB 1100
4030 GOSUB 5040
4032 X2=X%:Y2=Y%:TS1=SQR((X1-X2)^2+(Y1-Y2)^2)
4033 IF TS1<.5 THEN TINC=TINC+TINCTMP:GOTO 4028
4035 IF TS1>STP THEN TINC=.9*TINC: GOTO 4028
4040 REM PLOTF
4050 T=TMIN:GOSUB 1100
4055 CLR$="C"+STR$(240) 'curve colour
4056 DRAW CLR$
4060 MOVE$="B":GOSUB 5000
4075 FOR T=TMIN+TINC TO TMAX STEP TINC
4080 GOSUB 1100
4085 GOSUB 5000
4095 NEXT T
4100 REM
4110 IF ND$="N" THEN 4210' plot data sets
4112 DRAW "C255"
4125 FOR J=1 TO DTSN
4130 X=DATX(J):Y=DATY(J):MOVE$="B":GOSUB 5000
4140 GOSUB 7100
4205 NEXT J
4210 REM
4215 WHILE INKEY$="":WEND 'after plot wait for any key to be pressed.
4220 RETURN
5000 REM normal math coords -> plotter abs coords
5005 YPP=(Y-A4)*TEMPY:XPP=(X-B4)*TEMPX
5010 REM translate axes, & plot
5015 X%=XPP+HT%
5020 Y%=SZY%-(YPP+KT%)'Note screen y is downward in IBM-PC.
5025 REM Change coordinates into "plotting" form and send
5030 MOVE$=MOVE$+"M"+STR$(X%)+","+STR$(Y%)
5032 DRAW MOVE$
5035 MOVE$="" : RETURN 'RESET "pen up" to "down"
5040 REM TRANSL ONLY
5045 YPP=(Y-A4)*TEMPY:XPP=(X-B4)*TEMPX
5050 X%=XPP+HT%
5055 Y%=SZY%-(YPP+KT%):RETURN
6000 X%=XPP+HT% 'Locate nearest ascii spot
6010 Y%=SZY%-(YPP+KT%)
6020 ROW%=(Y%/SZY%*(25+YADD%)+.5):COL%=(X%/SZX%*80+.5)
6030 LOCATE ROW%,COL% :RETURN
7100 REM draw data symb1
7105 A$="BE2;D4;L4;U4;R4"
7110 DRAW A$
7199 RETURN
8000 A$=INKEY$:IF (A$="") GOTO 8000
8010 IF (ASC(A$)> 96) THEN A$=CHR$(ASC(A$)-32)
8020 RETURN
9000 PRINT" ERROR: VMODE selection or Function/data definition."
9005 PRINT" Press ─┘ for menu ";: INPUT"",A$: CHAIN "MENU"